<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" class="text">
    <div class="box"></div>
    <button class="btn">按钮</button>
</body>
</html>
<script>
    var obj={}
    var box=document.querySelector(".box")
    var text=document.querySelector(".text")
    Object.defineProperty(obj,"name",{
        get:function(){
            return val
        },
        set:function(newVal){
            text.value=newVal
            box.innerHTML=newVal
        }
        
    })
    text.addEventListener('input', function(e) {
            // 给obj的name属性赋值，进而触发该属性的set方法
            obj.name = e.target.value;
        });
        // obj.name = 'fei';

        var request = new XMLHttpRequest()
        request.open("POST",request_url)
        request.setRequestHeader("Content-type","application/json")
        send_data={"url":url,"name":"zhangsan","age":15}
        request.send(JSON.stringify(send_daat))
        request.onload=function(e){
            console.log("请求成功");
            console.log(request.readyState);
            if(request.status===200){
                alert('设置回调函数成功');
                window.history.back(-1)
            }else{
                alert('设置失败,请重试');
                window.history.back(-1)
            }
        }
        request.onerror=function(e){
            alert('请求失败');
        }
</script>